Feature/granular form field validation#683
Merged
Junirezz merged 2 commits intoJun 2, 2026
Merged
Conversation
…ing (Junirezz#511) - NEW: useNetworkStatus hook for browser connectivity detection * Subscribes to window online/offline events * Returns { isOnline: boolean } * Testable with fake timers and mocked navigator.onLine - NEW: useRetryState hook for tracking React Query retry cycles * Monitors query cache for error states * Computes seconds until next retry attempt * Returns { isRetrying: boolean, secondsUntilRetry: number | null } - ENHANCED: OfflineBanner component with retry countdown indicator * Offline state: Non-dismissible warning banner when device is offline * Retrying state: Shows countdown "Reconnecting... retrying in Xs" * Success state: Brief auto-dismissing success message on reconnection * Hidden state: Renders nothing when online and not retrying * ARIA attributes: role="alert" for offline (assertive), role="status" for retrying/success - UPDATED: Polling pause/resume for network awareness * useVaultData.ts: useVaultSummary(enabled: isOnline) pauses polling when offline * useFeeEstimate.ts: Added enabledNetworkPolling parameter for XLM price polling * useTvlTicker.ts: Added enabled parameter to pause TVL polling when offline * VaultContext.tsx: Passes isOnline to useVaultSummary * TvlTicker.tsx: Uses useNetworkStatus for polling control * VaultDashboard.tsx: Passes isOnline to useFeeEstimate - STYLING: Added .offline-banner--retrying variant (amber background) * Z-index: 1000 (above page content, below modals) * Auto-dismisses success after 4 seconds * Responsive layout with no text truncation - TESTS: Comprehensive unit tests * useNetworkStatus.test.ts: Online/offline transitions, event listener cleanup * useRetryState.test.ts: Query cache subscription, countdown logic * OfflineBanner.test.tsx: Enhanced tests for all banner states, ARIA attributes, icons Polling implementations now pause automatically when device goes offline and resume on reconnection. Users see a clear offline banner and retry countdown, improving connectivity awareness without manual intervention. Closes Junirezz#511
…hdraw forms (Junirezz#510) - Extract deposit and withdraw validation schemas to separate modules - Create DepositFormSchema with all business rules: minimum amount, balance check, capacity check, XLM fee check - Create WithdrawFormSchema with balance validation - Add server error mapping layer to sanitize and map backend errors to form fields - Enhance VaultDashboard to use new schemas with real-time validation feedback - Improve error handling with field-level and general error mapping - Maintain touched-state driven error display for better UX - Add comprehensive unit tests for all validation rules and error mapping Validation Rules: - Deposit: amount required, > 0, >= MIN_DEPOSIT (1 USDC), <= available balance, respects vault capacity, sufficient XLM for fees - Withdraw: amount required, > 0, <= available vault balance Error Display: - Per-field validation messages shown only after blur/touch - Real-time re-validation after first submit - Server errors mapped to matching form fields with sanitization - General server errors displayed as toast notifications Testing: - All validation rules tested with positive and negative cases - Error mapping sanitization prevents XSS and info leaks - Form submission integration tested CI Checks: - Type checking: tsc --noEmit passes - Linting: eslint passes - Tests: all unit tests pass - Build: npm run build succeeds
|
@Amas-01 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation: Issue #510 - Add Granular Form Field Validation Messages for Deposit and Withdraw Forms
Closes #510
Summary
The deposit and withdraw forms in YieldVault-RWA now have granular per-field validation feedback, providing users with actionable guidance when they submit invalid inputs. This implementation adds schema-driven validation rules, touched-state message display, submit guards, and server-error mapping to both forms so that users receive precise, per-field error messages before submission and clear feedback when the server rejects a request.
Files Modified and Created
Created Files
frontend/src/forms/schemas/depositFormSchema.ts- Deposit validation schema factoryfrontend/src/forms/schemas/depositFormSchema.test.ts- Deposit schema testsfrontend/src/forms/schemas/withdrawFormSchema.ts- Withdraw validation schema factoryfrontend/src/forms/schemas/withdrawFormSchema.test.ts- Withdraw schema testsfrontend/src/lib/errorMappers.ts- Server error mapping and sanitizationfrontend/src/lib/errorMappers.test.ts- Error mapping testsModified Files
frontend/src/components/VaultDashboard.tsx- Integrated new schemas, improved error handlingfrontend/src/forms/index.ts- Exported new schema factoriesValidation Rules Implementation Table
Server Error Response Field Mapping Table
amountamountbalanceamountTouched-State Configuration
onBlur(errors shown after blur event)Test Coverage Summary
Deposit Form Schema Tests
Withdraw Form Schema Tests
Error Mapping Tests
Submit Guard Tests
Server Error Mapping Tests
amounterror sets amount field errorAll CI Jobs (Frontend workflow)
Security Considerations
Documentation
errorMappers.ts